﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace SIS.Utilities.TextString
{
    public class RemoveHTMLTag
    {
        public RemoveHTMLTag()
        {
        }

        public string RemoveTailSpacing(string strOrgString)
        {
            return Regex.Replace(strOrgString, @"\s+", " ");
        }

        public string GetPlainString(string strOrgString)
        {
            return Regex.Replace(strOrgString, @"<(.|\n)*?>", string.Empty);
        }

        public string ClearScriptTag(string strSource)
        {
            String sourcestring = strSource;
            String matchpattern = @"<script[^>]*?.*?</script>";
            //String matchpattern = @"<script\s[^>]*?</script>";
            //String matchpattern = @"<script\s[^>]*>(?:(?!</script>).)*?\r\n(?:function blabla\(\)|blabla\(\);)(?:(?!</script>).)*?</script>";
            String replacementpattern = @"";
            String result = Regex.Replace(sourcestring, matchpattern, replacementpattern, RegexOptions.IgnoreCase);
            return result;
        }
    }
}
